package org.quipu.client;

import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import org.quipu.client.events.AppEvent;
import org.quipu.client.events.AppEventBus;
import org.quipu.client.events.AppEventListener;
import org.quipu.client.events.BookSelectionChangedEvent;
import org.quipu.client.events.LoginEvent;
import org.quipu.dto.CategoryDto;

public class CategoryEditPanel extends AppEventWidget implements AppEventListener {

    private final HorizontalPanel hPanel;
    private final CategoryTree inTree;
    private final CategoryTree outTree;

    public CategoryEditPanel(AppEventBus eventBus, AppCache cache) {
        super(eventBus, cache);
        hPanel = new HorizontalPanel();
        hPanel.addStyleName("controlPanel");
        inTree = new CategoryTree(eventBus, cache, CategoryDto.Type.INCOME);
        hPanel.add(inTree.getWidget());
        outTree = new CategoryTree(eventBus, cache, CategoryDto.Type.OUTCOME);
        hPanel.add(outTree.getWidget());
    }

    @Override
    public void init() {
        inTree.init();
        outTree.init();
    }

    @Override
    public Widget getWidget() {
        return hPanel;
    }

    @Override
    public void handleEvent(AppEvent event) {
        if(event != null) {
            if(event instanceof LoginEvent || event instanceof BookSelectionChangedEvent) {
                
            }
        }
    }
}
